import {service} from '@/utils/request'

// 系统管理API
export interface SystemLog {
  id: number
  timestamp: string
  level: string
  module: string
  message: string
  ip: string
  user: string
  details: string
}

export interface SystemLogListParams {
  page: number
  pageSize: number
  keyword?: string
  level?: string
  startTime?: string
  endTime?: string
}

export interface SystemLogListResponse {
  records: SystemLog[]
  total: number
  page: number
  pageSize: number
}

/**
 * 获取系统日志列表
 */
export const getSystemLogs = (params: SystemLogListParams) => {
  return service<SystemLogListResponse>({
    url: '/system/logs',
    method: 'get',
    params
  })
}

/**
 * 获取系统状态信息
 */
export const getSystemStatus = () => {
  return service({
    url: '/system/status',
    method: 'get'
  })
}

/**
 * 获取系统配置
 */
export const getSystemConfig = () => {
  return service({
    url: '/system/config',
    method: 'get'
  })
}

/**
 * 更新系统配置
 */
export const updateSystemConfig = (data: any) => {
  return service({
    url: '/system/config',
    method: 'put',
    data
  })
}